package com.ryan.statistic.controller;


import com.ryan.statistic.service.StatisticsDailyService;
import com.ryan.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 * 网站统计日数据 前端控制器
 * </p>
 *
 * @author ryan
 * @since 2020-08-03
 */
@RestController
@RequestMapping("/statistic/daily")
public class StatisticsDailyController {

    @Autowired
    private StatisticsDailyService dailyService;

    /**
     * 生成数据的方法
     * @param day
     * @return
     */
    @PostMapping("/createRegisterData/{day}")
    public R createRegisterData(@PathVariable String day){
        dailyService.createRegisterData(day);
        return R.ok();
    }

    @GetMapping("/showData/{type}/{begin}/{end}")
    public R showData(@PathVariable String type, @PathVariable String begin, @PathVariable String end){
        //返回的数据分别需要X轴和Y轴的两个数组，所以最好都放到map集合中返回
        Map<String, Object> map = dailyService.showData(type, begin, end);
        return R.ok().data(map);
    }


}

